package com.curd.jpa.business.entity;

import java.util.Date;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;


@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "dev_user")
public class User implements Serializable {
    protected static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    @Column(name = "id", columnDefinition="bigint(20) COMMENT '主键'")
    private Long id;

    @Column(name = "name", columnDefinition="varchar(64) COMMENT '姓名'", nullable = false)
    private String name;

    @Column(name = "age", columnDefinition="int(4) COMMENT '年龄'")
    private Integer age;

    @Column(name = "motto", columnDefinition="varchar(256) COMMENT '座右铭'")
    private String motto;

    @Column(name = "create_time", columnDefinition="datetime(0) COMMENT '创建时间'")
    @CreationTimestamp
    @DateTimeFormat(pattern="yyyy-MM-dd/HH:mm:ss")
    private Date createTime;

    @Column(name = "update_time", columnDefinition="datetime(0) COMMENT '更新时间'")
    @UpdateTimestamp
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
}
